package com.symaster.common.geom;

import com.alibaba.fastjson.JSONObject;
import com.symaster.common.geom.entity.Polygon;
import com.symaster.common.util.IOUtil;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.List;

/**
 * @author yinmiao
 * @version 2022-08-15 16:16
 */
public class Test {

    public static void main(String[] args) throws Exception {

        BufferedReader bufferedReader = null;
        String str;
        try {
            bufferedReader = new BufferedReader(new FileReader("D:\\startEdit\\projects\\common-zhongjia\\src\\test\\resources\\test.json"));
            str = bufferedReader.readLine();
        } finally {
            IOUtil.close(bufferedReader);
        }

        List<Polygon> polygons = JSONObject.parseArray(str, Polygon.class);

        Polygon polygon = polygons.get(0);

        long s = System.currentTimeMillis();

        for (int i2 = 0; i2 < 1000; i2++) {
            for (int i = 1; i < polygons.size(); i++) {
                polygon.collide(polygons.get(i));
                // System.out.println(collide);
            }
        }

        long e = System.currentTimeMillis();

        System.out.println(e - s);
    }
}
